package com.zc.controller.newController;

import com.zc.entity.Score;
import com.zc.service.echart.ScoreService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@CrossOrigin
@RequestMapping("/echart")
@Controller
public class EchartController {
    @Resource
    private ScoreService biz;
    @ResponseBody
    @RequestMapping(value = "/findAll" , method = RequestMethod.POST)
    public Map<String,Object> findAll(){
       List<Score> list= biz.findall();
        Map<String,Object> map=new HashMap();
        List<Integer> aa=new ArrayList();
        List<Integer> bb=new ArrayList();
        for(Score ss:list){
            aa.add(ss.getScore());
        }
        for(Score cc:list){
            bb.add(cc.getPersonNumber());
        }
        map.put("score",aa);
        map.put("person",bb);
        return map;
    }

    @RequestMapping("/aa")
    public String aa(){
        return "echart";
    }

}
